<template>
	<view class="com-search-filter">
		<view class="com-search-filter__search">
			<image class="com-search-filter__search-icon" :src="require('../static/search.png')"></image>
			<u-input class="com-search-filter__search-input" v-model="searchKey" :placeholder="placeholder" :border="false"
				placeholder-style="fontSize:28rpx;color:#86909C" :customStyle="{padding:'0'}" clearable
				@input="whenInput"></u-input>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			value: {
				type: String,
				default: ''
			},
			placeholder: {
				type: String,
				default: '请输入内容'
			},
		},
		data() {
			return {
				searchKey: '',
			}
		},
		watch: {
			value: {
				handler(nVal) {
					this.searchKey = nVal
				},
				immediate: true
			}
		},
		methods: {
			whenInput(e) {
				// console.log(e);
				this.$emit('input', e)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.com-search-filter {
		padding: 20rpx 32rpx;
		background-color: #fff;

		.com-search-filter__search {
			padding: 16rpx 24rpx;
			background-color: #F7F8FA;

			display: flex;
			align-items: center;

			.com-search-filter__search-icon {
				width: 32rpx;
				height: 32rpx;
				margin-right: 8rpx;
				flex: 0 0 auto;
			}

			.com-search-filter__search-input {
				width: 100%;
			}
		}
	}
</style>